home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
freetype.zip
/
tttypes.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-07
|
16KB
|
481 lines
{****************************************************************************}
{* *}
{* TTTypes *}
{* *}
{* This unit contains the data types used by the TrueType engine *}
{* *}
{****************************************************************************}
unit TTTypes;
interface
type
(* IntN types : *)
(* *)
(* These types are used as a way to garantee the size of some *)
(* specific integers. *)
(* *)
Int16 = Integer; (* 16 bits integer *)
Int32 = LongInt; (* 32 "" *)
Int64 = record (* 64 "" *)
Hi,
Lo : LongInt;
end;
(* BYTE is already defined in Pascal *)
(* They are equivalent to C unsigned chars *)
UShort = Word; (* unsigned short integer, must be on 16 bits *)
Short = Integer; (* signed short integer, must be on 16 bits *)
ShortRec = record
Low, (* a structure used for various type casts *)
High : Byte;
end;
ULong = LongInt; (* unsigned long integer, must be on 32 bits *)
(* NOTE : There is no 'LongWord' in Pascal, *)
(* but the unsigned ops are all in *)
(* the inline assembly routines *)
Long = LongInt; (* signed long integer, must be on 32 bits *)
Fixed = Longint; (* Signed Fixed 16.16 Float *)
FixedRec = record (* Structure used for various typecasts *)
Low,
High : Integer;
end;
FixedPoint = FixedRec;
{$IFDEF OS2}
Int = LongInt; (* the 'int' type is used for loop counters and *)
{$ELSE} (* indexes.. Their size must be the one a given *)
Int = Integer; (* system handles most easily ( 16 bits on Turbo *)
{$ENDIF} (* and 32 on Virtual Pascals ) *)
(* FUnits are the distance unit used for the EM square *)
FWord = Short; (* Distance in FUnits *)
UFWord = UShort; (* unsigned distance *)
F2Dot14 = Short; (* signed fixed float 2.14 used for unary vectors *)
(* Layout : *)
(* *)
(* s : 1 -- sign bit *)
(* m : 1 -- mantissa bit *)
(* f : 14 -- unsigned fractional part *)
(* *)
(* 's:m' is the 2-bit signed integer value to *)
(* which the positive fractional part should be *)
(* added. *)
(* *)
TUnitVector = record
x, y : F2Dot14; (* guess what ? *)
end;
F26Dot6 = LongInt; (* 26.6 Fixed float, used for glyph points' *)
(* pixel coordinates *)
TVector = record
x, y : F26Dot6; (* Simple pixel vector *)
end;
PVecTable = ^TVecTable;
TVecTable = Array[0..1000] of TVector;
(* a vector table type *)
PTouchTable = ^TTouchTable;
TTouchTable = Array[0..1000] of Byte;
(* a flag table type *)
TVecRecord = record
N : int; (* points number *)
Org : PVecTable; (* original coordinates from EM *)
Cur : PVecTable; (* current coordinates *)
Touch : PTouchTable; (* flags table *)
end;
(* This type defining a set of glyph points will be used to represent *)
(* each zones ( regular and twilight ) during instructions decoding *)
TContour = record
First, Last : Int;
end;
(* First and Last point index of a contour in a glyph *)
PContourTable = ^TContourTable;
TContourTable = array[0..15] of TContour;
(* A contour bounds table *)
TContourRecord = record
N : int; (* Contours numbers *)
C : PContourTable; (* Contours table *)
end;
(* This type is used to define the contours of each glyph *)
(* Simple access types : pointers and tables *)
PUShort = ^UShort;
PShort = ^Short;
PULong = ^ULong;
PLong = ^Long;
PFixed = ^Fixed;
PFixedRec = ^FixedRec;
TByteArray = array[0..63999] of Byte;
PByteArray = ^TByteArray;
PShortArray = ^TShortArray;
TShortArray = array[0..1023] of Integer;
TStorage = array[0..16000] of Long;
PStorage = ^TStorage;
TPoint = Record
GlyphNum : integer; (* this point's glyph number *)
V : TVector; (* current pixel position *)
Touch : Byte; (* touch flags *)
end;
PTTZone = ^TTTZone;
TTTZone = Array[0..1023] of TPoint;
TCVTRecord = record
N : int; (* size in 32 bits elements *)
A : PStorage; (* table address *)
end;
(* The CVT is a simple storage whose values are defined and used *)
(* by the font and glyphs programs *)
const
CTTFlagTouchedX = $01; (* X touched flag *)
CTTFlagTouchedY = $02; (* Y touched flag *)
(*****************************************************)
(* *)
(* TrueType Tables Types *)
(* *)
(*****************************************************)
type
(* Graphics State *)
(* *)
(* The Graphics State (GS) is managed by the *)
(* instruction field, but does not come from *)
(* the font file. Thus, we can use 'int's *)
(* where needed. *)
(* *)
PGraphicsState = ^TGraphicsState;
TGraphicsState = record
autoFlip : boolean;
controlValueCutIn : F26dot6;
deltaBase : int;
deltaShift : int;
dualVector,
projVector,
freeVector : TUnitVector;
gep0,
gep1,
gep2 : int;
instructControl : byte;
loop : Int32;
minimumDistance : F26dot6;
roundState : int;
rp0,
rp1,
rp2 : int;
scanControl : boolean;
singleWidthCutIn : F26dot6;
singleWidthValue : F26dot6;
end;
(* TrueType Table Directory type *)
TTableDir = Record
version : FixedPoint; (* should be $10000 *)
numTables : word; (* Tables number *)
search